package com.shsubway.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 * Created by Hu on 2016/9/25.
 */

public abstract class BaseFragment extends Fragment {
    public Context context;
    public SharedPreferences remember;
    public ProgressDialog mDialog;
    boolean isViewCreated;
    public BaseActivity activity;
    public View emptyView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        activity = (BaseActivity) getActivity();
        this.emptyView=activity.emptyView;
        context=getContext();
        View rootView = inflater.inflate(getLayout(), container, false);
        initViews(rootView);
        isViewCreated = true;
        return rootView;
    }

    public abstract int getLayout();

    public abstract void initViews(View rootView);

    public <T> T $(int viewID, View heardView) {
        return (T) heardView.findViewById(viewID);
    }
    public void setRecy(RecyclerView recy) {
        activity.setRecy(recy);
    }
}
